import time

from PyQt5.QtCore import QObject, pyqtSignal, QThread

from base_api.MessageClass import Message


class HelloWorldSignalThread(QThread):
    signal = pyqtSignal(object)

    def __init__(self):
        super().__init__()
        self.name = ''

    def run(self):
        # pyqtSignal+QThread解决未响应和线程竞争ui资源问题
        time.sleep(5)
        self.signal.emit(Message(1, 'Hello world, %s' % self.name))
        self.signal.emit(Message(1, '123'))
        # 线程执行完毕
        self.signal.emit(Message(-1, ''))